﻿CREATE TABLE [dbo].[Transaction] (
    [TransactionID] INT          IDENTITY (1, 1) NOT NULL,
    [CorrelationID] INT          NOT NULL,
    [Sell]          BIT          NOT NULL,
    [PortfolioID]   INT          NOT NULL,
    [SecurityID]    INT          NOT NULL,
    [Quantity]      INT          NOT NULL,
    [PurchaseDate]  DATETIME     NULL,
    [SellingDate]   DATETIME     NULL,
    [PurchasePrice] SMALLMONEY   NULL,
    [SellingPrice]  SMALLMONEY   NULL,
    [Commission]    SMALLMONEY   NULL,
    [StrategyID]    INT          NULL,
    [Parameters]    VARCHAR (50) NULL,
    CONSTRAINT [PK_Transaction] PRIMARY KEY CLUSTERED ([TransactionID] ASC),
    CONSTRAINT [FK_Transaction_Portfolio] FOREIGN KEY ([PortfolioID]) REFERENCES [dbo].[Portfolio] ([PortefolioID]),
    CONSTRAINT [FK_Transaction_Security] FOREIGN KEY ([SecurityID]) REFERENCES [dbo].[Security] ([SecurityID]),
    CONSTRAINT [FK_Transaction_Strategy] FOREIGN KEY ([StrategyID]) REFERENCES [dbo].[Strategy] ([StrategyID])
);

